<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="author" content="lcy">
    <title></title>
    <style>
        
    </style>
</head>
<body>
    
</body>
</html>
<script>
    function  People(name,age,isMale){
        this.name=name;
        this.age=age;
        this.isMale=isMale;
    }
    People.prototype.say=function(){
        console.log(this.name+'说Hello');
    }
    var peo=new People('张三',22,true);
    console.log(peo);
    peo.say();


    function Boy(name,age,isMale){
        // 调用people对象 改变this的指向
       People.call(this,name,age,isMale); 
    }
    // 继承people的方法
    function empty(){};
    // empty继承了people的原型 设置一个空对象是为了让其他再继承时不会产生多余的属性
    empty.prototype=People.prototype;
    // 让boy继承empty的原型 这样发生改变时只会改变该对象对其原型没有影响
    Boy.prototype=new empty();

    Boy.prototype.constructor=Boy;
    Boy.prototype.play=function(game,hours){
        console.log(this.name+game+hours);
    }
    var boy=new Boy('ll',21,false);
    console.log(boy);
    boy.play('消消乐',16+'小时');
    boy.say();

    function Girl(name,age,isMale){
        People.call(this,name,age,isMale);
        // this.isLongHair=isLongHair;
        Object.defineProperty(this,'isLongHair',{
            value:true,
            writable:true,
            configurable:true,
            enumerable:true,
        })
    }
    
    function em(){};
    em.prototype=People.prototype;
    Girl.prototype=new em();

    Girl.prototype.constructor=Girl;
    Girl.prototype.goShopping=function(place,hours){
        console.log(this.name+'去'+place+'逛街'+hours+'个小时');
    }
    var girl=new Girl('李思',11,false,true);
    console.log(girl); 
    girl.goShopping('二七广场',3);   
    girl.say(); 
</script>